package com.sh.data.engine.application.service.management;

import com.sh.data.engine.application.model.dto.base.PagerResponse;
import com.sh.data.engine.application.model.dto.management.OperationLogDTO;
import com.sh.data.engine.application.model.mapper.management.OperationLogDTOPageMapper;
import com.sh.data.engine.domain.management.model.param.OperationLogQueryParam;
import com.sh.data.engine.domain.management.service.OperationService;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;

@Slf4j
@Service
public class OperationLogApplicationService {
    @Autowired
    private OperationService operationService;
    @Autowired
    private OperationLogDTOPageMapper operationLogDTOPageMapper;

    public PagerResponse<OperationLogDTO> getLogPageList(
            OperationLogQueryParam param) {
        var dsPageList = operationService.getLogPageList(param);
        return operationLogDTOPageMapper.toPageResponse(dsPageList);
    }

    public void exportOperationLogs(
            OperationLogQueryParam param, HttpServletResponse response) throws IOException {
        operationService.exportLogsToExcel(param, response);
    }

}
